<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>添加微信</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      text-align: center;
      font-family: Arial, sans-serif;
      padding: 50px;
    }
    .tip {
      font-size: 18px;
      color: #333;
    }
    .btn {
      margin-top: 20px;
      display: inline-block;
      background-color: #07c160;
      color: #fff;
      padding: 12px 24px;
      border-radius: 8px;
      text-decoration: none;
      font-size: 16px;
    }
  </style>
</head>
<body>
  <div class="tip" id="message">
    正在跳转微信添加好友...
  </div>
  <script>
    const isWeChat = /micromessenger/i.test(navigator.userAgent);
    const weixinUrl = "weixin://contacts/profile/cangxia888"; // 修改微信号

    if (isWeChat) {
      document.getElementById('message').innerHTML = `
        当前为微信内访问，请点击右上角菜单<br>选择「在浏览器中打开」后再添加微信好友。
      `;
    } else {
      window.location.href = weixinUrl;

      setTimeout(() => {
        document.getElementById('message').innerHTML = `
          如果没有自动跳转，请点击下方按钮手动添加微信：
          <br><a class="btn" href="${weixinUrl}">添加微信好友</a>
        `;
      }, 2000);
    }
  </script>
</body>
</html>
